package com.lsw.redisspringboot.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lsw.redisspringboot.entity.EduTeacher;
import com.lsw.redisspringboot.mapper.EduTeacherMapper;
import com.lsw.redisspringboot.service.EduTeacherService;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author lsw
 * @since 2020-04-02
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher> implements EduTeacherService {


    @Override
    @Cacheable(value = "teacher", key = "'findAllTeachers'")
    public List<EduTeacher> findAllTeachers() {
        return baseMapper.selectList(null);
    }

    @Override
    @CachePut(value = "teacher", key = "'findAllTeachers'")
    public boolean addTeacher(EduTeacher eduTeacher) {
        return baseMapper.insert(eduTeacher)>0?true:false;

    }
}
